import Vue from 'vue'
import App from './App.vue'

//导入路由
import router from './router/'
//注册全局组件
import  './plugins/index'
//导入全局样式
import './assets/css/global.css'
// 通信
import Store from './plugins/store'


import axios from 'axios'
//配置请求的根路径
axios.defaults.baseURL = "http://127.0.0.1:3007/"
axios.interceptors.request.use(config=>{
  config.headers.Authorization = window.sessionStorage.getItem('token') || []
  //在最后必须要return config
  return config
})
axios.interceptors.response.use(config=>{
  return config
})   

Vue.prototype.$http=axios
// Vue.prototype.$bus=Store

Vue.config.productionTip = false

Vue.filter('dateFormat',function(originVal){
  const dt = new Date(originVal)

  const y = dt.getFullYear()
  const m = (dt.getMonth() +1 +'').padStart(2,'0')
  const d = (dt.getDate() + '').padStart(2,'0')
  
  return `${y}-${m}-${d}`
})

new Vue({
  render: h => h(App),
  router,
}).$mount('#app')
